package com.ms.pda.messenger

import androidx.lifecycle.MutableLiveData
import com.ms.pda.base.BaseActivity
import com.ms.pda.base.BaseViewModel
import java.lang.Exception
import java.util.function.Consumer

class LoginMessenger : BaseViewModel() {

    val account: MutableLiveData<String> = MutableLiveData("")
    val password: MutableLiveData<String> = MutableLiveData("")

    /**
     * 登录
     */
    fun login(
        activity: BaseActivity,
        consumer: Consumer<Boolean>
    ) {
        if ("admin" != account.value) {
            handleResponseError(Exception("用户名错误"))
        } else if ("admin123" != password.value) {
            handleResponseError(Exception("密码错误"))
        } else {
            consumer.accept(true)
        }
    }
}